const service = require("../services/order");

class Controller {
    async list(req, res) {
        try {
            const body = await service.list();
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }
    async add(req, res) {
        try {
            const body = await service.add(req.body);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }
    async update(req, res) {
        try {
            const body = await service.update(req.body);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }
    async del(req, res) {
        try {
            const body = await service.del(req.body);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }
}

module.exports = new Controller();
